﻿using ReadyApps.Wiki;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ReadyAppsTest.Models.Wiki
{
    /// <summary>
    ///This is a test class for WikiPageTextTest and is intended
    ///to contain all WikiPageTextTest Unit Tests
    ///</summary>
    [TestClass()]
    public class WikiPageTextTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [TestMethod()]
        public void WikiPageTextConstructorTest()
        {
            string text = "test";
            WikiPageText target = new WikiPageText(text);
            PrivateObject targetWrapper = new PrivateObject(target);
            Assert.AreEqual(text, (string)targetWrapper.GetProperty("Text"));
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void WikiPageTextConstructorNullTest()
        {
            string text = null;
            WikiPageText target = new WikiPageText(text);
        }

        [TestMethod()]
        public void GetControlTest()
        {
            string text = "test";
            WikiPageText target = new WikiPageText(text);
            Control expected = new Literal() { Text = text };
            Control actual;
            actual = target.GetControl();
            Assert.IsInstanceOfType(actual, typeof(Literal));
            Assert.AreEqual(((Literal)actual).Text, text);
        }

        [TestMethod()]
        public void GetControlEmptyTest()
        {
            string text = string.Empty;
            WikiPageText target = new WikiPageText(text);
            Control expected = new Literal() { Text = text };
            Control actual;
            actual = target.GetControl();
            Assert.IsInstanceOfType(actual, typeof(Literal));
            Assert.AreEqual(((Literal)actual).Text, text);
        }

        [TestMethod()]
        public void GetMarkupTest()
        {
            string text = "test";
            WikiPageText target = new WikiPageText(text);
            string expected = "test";
            string actual;
            actual = target.GetMarkup();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetMarkupEmptyTest()
        {
            string text = string.Empty;
            WikiPageText target = new WikiPageText(text);
            string expected = string.Empty;
            string actual;
            actual = target.GetMarkup();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void TextTest()
        {
            string text = "text";
            WikiPageText target = new WikiPageText(text);
            PrivateObject targetWrapper = new PrivateObject(target);
            string newText = "newText";
            targetWrapper.SetProperty("Text", newText);
            Assert.AreEqual(newText, (string)targetWrapper.GetProperty("Text"));
        }

        [TestMethod]
        public void EqualsTest()
        {
            WikiPageText target = new WikiPageText("test");
            WikiPageText other = new WikiPageText("test");
            Assert.IsTrue(target.Equals(other));
            other = new WikiPageText("not test");
            Assert.IsFalse(target.Equals(other));
        }
    }
}
